import { Modal } from "ant-design-vue";
import { confirmTypes, InfoTypes } from './types'

/**
 * antd confirm
 */
 export const antdModalConfirm = ({
  title = "确认操作？",
  content,
}: confirmTypes): Promise<void> => {
  return new Promise((resolve, reject) => {
    Modal.confirm({
      title: title,
      content: content,
      okText: "确认",
      cancelText: "取消",
      onOk: () => {
        resolve();
      },
      onCancel: () => {
        reject();
      },
    });
  });
};

/**
 * info
 */
// info/success/error/warning
export const antdModalInfo = (params: InfoTypes): Promise<void> => {
  const { type, title, content } = params;
  return new Promise((resolve, reject) => {
    Modal[type]({
      title: title,
      content: content,
      onOk: () => {
        resolve();
      },
    });
  });
};
